//
// @Auther: by wujehy 
// @Email:wujehy@qq.com
// @Data:2020/9/11
// @Time:1:28 下午
//
//

#include <iostream>
#include <base_types.h>
#include <csignal>
#include "AppManager.h"
// 使用日志系统的日志
#include "glog/logging.h"
#include "ServerMod/AuthMod.h"
#include "ServerMod/KeyValueMod.h"
#include "ServerMod/TestMod.h"

using namespace GeeJoan;
AppManager *app;

int main()
{
    try
    {
        AppManager appManager;


        // 注册 方法1
        appManager.registerModFunc(new AuthMod);

        // 方法2
        appManager.init_before_callback = [](AppManager *app){
            // 初始化之前注册
            app->registerModFunc(new KeyValueMod);
            app->registerModFunc(new TestMod);
        };
        //设置端口

        //设置端口
        appManager.setPort(10000);
        appManager.setLogPath(".");
        appManager.init_local();

        app = &appManager;

        signal(SIGINT, [](int s)
        {
            LOGINFO << " exit ";
            app->stop();
        });

        signal(SIGTERM, [](int s)
        {
            LOGINFO << " exit ";
            app->stop();
        });
        app->init_network();
        app->run();
    }
    catch (std::exception &e)
    {
        std::cerr << "Exception: " << e.what() << "\n";
    }
    return 0;
}